5f391fcfa968f86be6af4622c37ca9ed1426dffa,source/de/anomic/data/wiki/wikiCode.java,wikiCode,processTable,#String#,108

Before Change


            if (propEnd == cellEnd) {
                propEnd = lenCellDivider;
            } else {
                line += parseTableProperties(input.substring(lenCellDivider, propEnd - lenAttribDivider).trim()).toString();
            }
            // quick&dirty fix [MN]
            if (propEnd > cellEnd) {

After Change


     */
    private String processTable(final String line) {
        //some variables that make it easier to change codes for the table
        final StringBuilder out = new StringBuilder();
        final String tableStart = "{" + PIPE_ESCAPED;        // {|
        final String newLine = PIPE_ESCAPED + "-";                // |-
        final String cellDivider = PIPE_ESCAPED + PIPE_ESCAPED;   // ||
        final String tableEnd = PIPE_ESCAPED + "}";          // |}
        final String attribDivider = PIPE_ESCAPED;                // |
        final int lenTableStart = tableStart.length();
        final int lenCellDivider = cellDivider.length();
        final int lenTableEnd = tableEnd.length();
        final int lenAttribDivider = attribDivider.length();

        if ((line.startsWith(tableStart)) && (!processingTable)) {
            processingTable = true;
            newRowStart = true;
            out.append("<table");
            if (line.trim().length() > lenTableStart) {
                out.append(filterTableProperties(line.substring(lenTableStart).trim()));
            }
            out.append(">");
        } else if (line.startsWith(newLine) && (processingTable)) {          // new row
            if (!newRowStart) {
                out.append("\t</tr>\n");
            } else {
                newRowStart = false;
            }
            out.append("\t<tr>");
        } else if ((line.startsWith(cellDivider)) && (processingTable)) {
            out.append("\t\t<td");
            final int cellEnd = (line.indexOf(cellDivider, lenCellDivider) > 0) ? (line.indexOf(cellDivider, lenCellDivider)) : (line.length());
            int propEnd = line.indexOf(attribDivider, lenCellDivider);
            final int occImage = line.indexOf("[[Image:", lenCellDivider);
            final int occEscape = line.indexOf("[=", lenCellDivider);
            //If resultOf("[[Image:") is less than propEnd, that means that there is no
            //property for this cell, only an image. Without this, YaCy could get confused
            //by a | in [[Image:picture.png|alt-text]] or [[Image:picture.png|alt-text]]
            //Same for [= (part of [= =])
            if ((propEnd > lenCellDivider) && ((occImage > propEnd) || (occImage < 0)) && ((occEscape > propEnd) || (occEscape < 0))) {
                propEnd = line.indexOf(attribDivider, lenCellDivider) + lenAttribDivider;
            } else {
                propEnd = cellEnd;
            }
            // both point at same place => new line
            if (propEnd == cellEnd) {
                propEnd = lenCellDivider;
            } else {
                out.append(filterTableProperties(line.substring(lenCellDivider, propEnd - lenAttribDivider).trim()));
            }
            // quick&dirty fix [MN]
            if (propEnd > cellEnd) {
                propEnd = lenCellDivider;
            }
            processingTable = false;
            processingCell = true;
            out.append(">");
            out.append(processTable(line.substring(propEnd, cellEnd).trim()));
            out.append("</td>");
            processingTable = true;
            processingCell = false;
            if (cellEnd < line.length()) {
                out.append("\n");
                out.append(processTable(line.substring(cellEnd)));
            }
        } else if (line.startsWith(tableEnd) && (processingTable)) {          // Table end
            processingTable = false;
            out.append("\t</tr>\n</table>");
            out.append(line.substring(lenTableEnd));
        } else {
            out.append(line);
        }
        return out.toString();
    }

    // contributed by [MN], changes by [FB]